Left Termination of the query pattern query_in_1(g) w.r.t. the given Prolog program could successfully be proven:



Prolog
  ↳ PrologToPiTRSProof

Clauses:

append(nil, XS, XS).
append(cons(X, XS), YS, cons(X, ZS)) :- append(XS, YS, ZS).
reverse(nil, nil).
reverse(cons(X, nil), cons(X, nil)).
reverse(cons(X, XS), YS) :- ','(reverse(XS, ZS), append(ZS, cons(X, nil), YS)).
shuffle(nil, nil).
shuffle(cons(X, XS), cons(X, YS)) :- ','(reverse(XS, ZS), shuffle(ZS, YS)).
query(XS) :- shuffle(cons(X, XS), YS).

Queries:

query(g).

We use the technique of [30].Transforming Prolog into the following Term Rewriting System:
Pi-finite rewrite system:
The TRS R consists of the following rules:

query_in(XS) → U6(XS, shuffle_in(cons(X, XS), YS))
shuffle_in(cons(X, XS), cons(X, YS)) → U4(X, XS, YS, reverse_in(XS, ZS))
reverse_in(cons(X, XS), YS) → U2(X, XS, YS, reverse_in(XS, ZS))
reverse_in(cons(X, nil), cons(X, nil)) → reverse_out(cons(X, nil), cons(X, nil))
reverse_in(nil, nil) → reverse_out(nil, nil)
U2(X, XS, YS, reverse_out(XS, ZS)) → U3(X, XS, YS, append_in(ZS, cons(X, nil), YS))
append_in(cons(X, XS), YS, cons(X, ZS)) → U1(X, XS, YS, ZS, append_in(XS, YS, ZS))
append_in(nil, XS, XS) → append_out(nil, XS, XS)
U1(X, XS, YS, ZS, append_out(XS, YS, ZS)) → append_out(cons(X, XS), YS, cons(X, ZS))
U3(X, XS, YS, append_out(ZS, cons(X, nil), YS)) → reverse_out(cons(X, XS), YS)
U4(X, XS, YS, reverse_out(XS, ZS)) → U5(X, XS, YS, shuffle_in(ZS, YS))
shuffle_in(nil, nil) → shuffle_out(nil, nil)
U5(X, XS, YS, shuffle_out(ZS, YS)) → shuffle_out(cons(X, XS), cons(X, YS))
U6(XS, shuffle_out(cons(X, XS), YS)) → query_out(XS)

The argument filtering Pi contains the following mapping:
query_in(x1)  =  query_in(x1)
U6(x1, x2)  =  U6(x2)
shuffle_in(x1, x2)  =  shuffle_in(x1)
cons(x1, x2)  =  cons(x2)
U4(x1, x2, x3, x4)  =  U4(x4)
reverse_in(x1, x2)  =  reverse_in(x1)
U2(x1, x2, x3, x4)  =  U2(x4)
nil  =  nil
reverse_out(x1, x2)  =  reverse_out(x2)
U3(x1, x2, x3, x4)  =  U3(x4)
append_in(x1, x2, x3)  =  append_in(x1, x2)
U1(x1, x2, x3, x4, x5)  =  U1(x5)
append_out(x1, x2, x3)  =  append_out(x3)
U5(x1, x2, x3, x4)  =  U5(x4)
shuffle_out(x1, x2)  =  shuffle_out(x2)
query_out(x1)  =  query_out

Infinitary Constructor Rewriting Termination of PiTRS implies Termination of Prolog



↳ Prolog
  ↳ PrologToPiTRSProof
PiTRS
      ↳ DependencyPairsProof

Pi-finite rewrite system:
The TRS R consists of the following rules:

query_in(XS) → U6(XS, shuffle_in(cons(X, XS), YS))
shuffle_in(cons(X, XS), cons(X, YS)) → U4(X, XS, YS, reverse_in(XS, ZS))
reverse_in(cons(X, XS), YS) → U2(X, XS, YS, reverse_in(XS, ZS))
reverse_in(cons(X, nil), cons(X, nil)) → reverse_out(cons(X, nil), cons(X, nil))
reverse_in(nil, nil) → reverse_out(nil, nil)
U2(X, XS, YS, reverse_out(XS, ZS)) → U3(X, XS, YS, append_in(ZS, cons(X, nil), YS))
append_in(cons(X, XS), YS, cons(X, ZS)) → U1(X, XS, YS, ZS, append_in(XS, YS, ZS))
append_in(nil, XS, XS) → append_out(nil, XS, XS)
U1(X, XS, YS, ZS, append_out(XS, YS, ZS)) → append_out(cons(X, XS), YS, cons(X, ZS))
U3(X, XS, YS, append_out(ZS, cons(X, nil), YS)) → reverse_out(cons(X, XS), YS)
U4(X, XS, YS, reverse_out(XS, ZS)) → U5(X, XS, YS, shuffle_in(ZS, YS))
shuffle_in(nil, nil) → shuffle_out(nil, nil)
U5(X, XS, YS, shuffle_out(ZS, YS)) → shuffle_out(cons(X, XS), cons(X, YS))
U6(XS, shuffle_out(cons(X, XS), YS)) → query_out(XS)

The argument filtering Pi contains the following mapping:
query_in(x1)  =  query_in(x1)
U6(x1, x2)  =  U6(x2)
shuffle_in(x1, x2)  =  shuffle_in(x1)
cons(x1, x2)  =  cons(x2)
U4(x1, x2, x3, x4)  =  U4(x4)
reverse_in(x1, x2)  =  reverse_in(x1)
U2(x1, x2, x3, x4)  =  U2(x4)
nil  =  nil
reverse_out(x1, x2)  =  reverse_out(x2)
U3(x1, x2, x3, x4)  =  U3(x4)
append_in(x1, x2, x3)  =  append_in(x1, x2)
U1(x1, x2, x3, x4, x5)  =  U1(x5)
append_out(x1, x2, x3)  =  append_out(x3)
U5(x1, x2, x3, x4)  =  U5(x4)
shuffle_out(x1, x2)  =  shuffle_out(x2)
query_out(x1)  =  query_out


Using Dependency Pairs [1,30] we result in the following initial DP problem:
Pi DP problem:
The TRS P consists of the following rules:

QUERY_IN(XS) → U61(XS, shuffle_in(cons(X, XS), YS))
QUERY_IN(XS) → SHUFFLE_IN(cons(X, XS), YS)
SHUFFLE_IN(cons(X, XS), cons(X, YS)) → U41(X, XS, YS, reverse_in(XS, ZS))
SHUFFLE_IN(cons(X, XS), cons(X, YS)) → REVERSE_IN(XS, ZS)
REVERSE_IN(cons(X, XS), YS) → U21(X, XS, YS, reverse_in(XS, ZS))
REVERSE_IN(cons(X, XS), YS) → REVERSE_IN(XS, ZS)
U21(X, XS, YS, reverse_out(XS, ZS)) → U31(X, XS, YS, append_in(ZS, cons(X, nil), YS))
U21(X, XS, YS, reverse_out(XS, ZS)) → APPEND_IN(ZS, cons(X, nil), YS)
APPEND_IN(cons(X, XS), YS, cons(X, ZS)) → U11(X, XS, YS, ZS, append_in(XS, YS, ZS))
APPEND_IN(cons(X, XS), YS, cons(X, ZS)) → APPEND_IN(XS, YS, ZS)
U41(X, XS, YS, reverse_out(XS, ZS)) → U51(X, XS, YS, shuffle_in(ZS, YS))
U41(X, XS, YS, reverse_out(XS, ZS)) → SHUFFLE_IN(ZS, YS)

The TRS R consists of the following rules:

query_in(XS) → U6(XS, shuffle_in(cons(X, XS), YS))
shuffle_in(cons(X, XS), cons(X, YS)) → U4(X, XS, YS, reverse_in(XS, ZS))
reverse_in(cons(X, XS), YS) → U2(X, XS, YS, reverse_in(XS, ZS))
reverse_in(cons(X, nil), cons(X, nil)) → reverse_out(cons(X, nil), cons(X, nil))
reverse_in(nil, nil) → reverse_out(nil, nil)
U2(X, XS, YS, reverse_out(XS, ZS)) → U3(X, XS, YS, append_in(ZS, cons(X, nil), YS))
append_in(cons(X, XS), YS, cons(X, ZS)) → U1(X, XS, YS, ZS, append_in(XS, YS, ZS))
append_in(nil, XS, XS) → append_out(nil, XS, XS)
U1(X, XS, YS, ZS, append_out(XS, YS, ZS)) → append_out(cons(X, XS), YS, cons(X, ZS))
U3(X, XS, YS, append_out(ZS, cons(X, nil), YS)) → reverse_out(cons(X, XS), YS)
U4(X, XS, YS, reverse_out(XS, ZS)) → U5(X, XS, YS, shuffle_in(ZS, YS))
shuffle_in(nil, nil) → shuffle_out(nil, nil)
U5(X, XS, YS, shuffle_out(ZS, YS)) → shuffle_out(cons(X, XS), cons(X, YS))
U6(XS, shuffle_out(cons(X, XS), YS)) → query_out(XS)

The argument filtering Pi contains the following mapping:
query_in(x1)  =  query_in(x1)
U6(x1, x2)  =  U6(x2)
shuffle_in(x1, x2)  =  shuffle_in(x1)
cons(x1, x2)  =  cons(x2)
U4(x1, x2, x3, x4)  =  U4(x4)
reverse_in(x1, x2)  =  reverse_in(x1)
U2(x1, x2, x3, x4)  =  U2(x4)
nil  =  nil
reverse_out(x1, x2)  =  reverse_out(x2)
U3(x1, x2, x3, x4)  =  U3(x4)
append_in(x1, x2, x3)  =  append_in(x1, x2)
U1(x1, x2, x3, x4, x5)  =  U1(x5)
append_out(x1, x2, x3)  =  append_out(x3)
U5(x1, x2, x3, x4)  =  U5(x4)
shuffle_out(x1, x2)  =  shuffle_out(x2)
query_out(x1)  =  query_out
REVERSE_IN(x1, x2)  =  REVERSE_IN(x1)
QUERY_IN(x1)  =  QUERY_IN(x1)
SHUFFLE_IN(x1, x2)  =  SHUFFLE_IN(x1)
U51(x1, x2, x3, x4)  =  U51(x4)
U61(x1, x2)  =  U61(x2)
U31(x1, x2, x3, x4)  =  U31(x4)
U41(x1, x2, x3, x4)  =  U41(x4)
APPEND_IN(x1, x2, x3)  =  APPEND_IN(x1, x2)
U21(x1, x2, x3, x4)  =  U21(x4)
U11(x1, x2, x3, x4, x5)  =  U11(x5)

We have to consider all (P,R,Pi)-chains

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
PiDP
          ↳ DependencyGraphProof

Pi DP problem:
The TRS P consists of the following rules:

QUERY_IN(XS) → U61(XS, shuffle_in(cons(X, XS), YS))
QUERY_IN(XS) → SHUFFLE_IN(cons(X, XS), YS)
SHUFFLE_IN(cons(X, XS), cons(X, YS)) → U41(X, XS, YS, reverse_in(XS, ZS))
SHUFFLE_IN(cons(X, XS), cons(X, YS)) → REVERSE_IN(XS, ZS)
REVERSE_IN(cons(X, XS), YS) → U21(X, XS, YS, reverse_in(XS, ZS))
REVERSE_IN(cons(X, XS), YS) → REVERSE_IN(XS, ZS)
U21(X, XS, YS, reverse_out(XS, ZS)) → U31(X, XS, YS, append_in(ZS, cons(X, nil), YS))
U21(X, XS, YS, reverse_out(XS, ZS)) → APPEND_IN(ZS, cons(X, nil), YS)
APPEND_IN(cons(X, XS), YS, cons(X, ZS)) → U11(X, XS, YS, ZS, append_in(XS, YS, ZS))
APPEND_IN(cons(X, XS), YS, cons(X, ZS)) → APPEND_IN(XS, YS, ZS)
U41(X, XS, YS, reverse_out(XS, ZS)) → U51(X, XS, YS, shuffle_in(ZS, YS))
U41(X, XS, YS, reverse_out(XS, ZS)) → SHUFFLE_IN(ZS, YS)

The TRS R consists of the following rules:

query_in(XS) → U6(XS, shuffle_in(cons(X, XS), YS))
shuffle_in(cons(X, XS), cons(X, YS)) → U4(X, XS, YS, reverse_in(XS, ZS))
reverse_in(cons(X, XS), YS) → U2(X, XS, YS, reverse_in(XS, ZS))
reverse_in(cons(X, nil), cons(X, nil)) → reverse_out(cons(X, nil), cons(X, nil))
reverse_in(nil, nil) → reverse_out(nil, nil)
U2(X, XS, YS, reverse_out(XS, ZS)) → U3(X, XS, YS, append_in(ZS, cons(X, nil), YS))
append_in(cons(X, XS), YS, cons(X, ZS)) → U1(X, XS, YS, ZS, append_in(XS, YS, ZS))
append_in(nil, XS, XS) → append_out(nil, XS, XS)
U1(X, XS, YS, ZS, append_out(XS, YS, ZS)) → append_out(cons(X, XS), YS, cons(X, ZS))
U3(X, XS, YS, append_out(ZS, cons(X, nil), YS)) → reverse_out(cons(X, XS), YS)
U4(X, XS, YS, reverse_out(XS, ZS)) → U5(X, XS, YS, shuffle_in(ZS, YS))
shuffle_in(nil, nil) → shuffle_out(nil, nil)
U5(X, XS, YS, shuffle_out(ZS, YS)) → shuffle_out(cons(X, XS), cons(X, YS))
U6(XS, shuffle_out(cons(X, XS), YS)) → query_out(XS)

The argument filtering Pi contains the following mapping:
query_in(x1)  =  query_in(x1)
U6(x1, x2)  =  U6(x2)
shuffle_in(x1, x2)  =  shuffle_in(x1)
cons(x1, x2)  =  cons(x2)
U4(x1, x2, x3, x4)  =  U4(x4)
reverse_in(x1, x2)  =  reverse_in(x1)
U2(x1, x2, x3, x4)  =  U2(x4)
nil  =  nil
reverse_out(x1, x2)  =  reverse_out(x2)
U3(x1, x2, x3, x4)  =  U3(x4)
append_in(x1, x2, x3)  =  append_in(x1, x2)
U1(x1, x2, x3, x4, x5)  =  U1(x5)
append_out(x1, x2, x3)  =  append_out(x3)
U5(x1, x2, x3, x4)  =  U5(x4)
shuffle_out(x1, x2)  =  shuffle_out(x2)
query_out(x1)  =  query_out
REVERSE_IN(x1, x2)  =  REVERSE_IN(x1)
QUERY_IN(x1)  =  QUERY_IN(x1)
SHUFFLE_IN(x1, x2)  =  SHUFFLE_IN(x1)
U51(x1, x2, x3, x4)  =  U51(x4)
U61(x1, x2)  =  U61(x2)
U31(x1, x2, x3, x4)  =  U31(x4)
U41(x1, x2, x3, x4)  =  U41(x4)
APPEND_IN(x1, x2, x3)  =  APPEND_IN(x1, x2)
U21(x1, x2, x3, x4)  =  U21(x4)
U11(x1, x2, x3, x4, x5)  =  U11(x5)

We have to consider all (P,R,Pi)-chains
The approximation of the Dependency Graph [30] contains 3 SCCs with 8 less nodes.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
PiDP
                ↳ UsableRulesProof
              ↳ PiDP
              ↳ PiDP

Pi DP problem:
The TRS P consists of the following rules:

APPEND_IN(cons(X, XS), YS, cons(X, ZS)) → APPEND_IN(XS, YS, ZS)

The TRS R consists of the following rules:

query_in(XS) → U6(XS, shuffle_in(cons(X, XS), YS))
shuffle_in(cons(X, XS), cons(X, YS)) → U4(X, XS, YS, reverse_in(XS, ZS))
reverse_in(cons(X, XS), YS) → U2(X, XS, YS, reverse_in(XS, ZS))
reverse_in(cons(X, nil), cons(X, nil)) → reverse_out(cons(X, nil), cons(X, nil))
reverse_in(nil, nil) → reverse_out(nil, nil)
U2(X, XS, YS, reverse_out(XS, ZS)) → U3(X, XS, YS, append_in(ZS, cons(X, nil), YS))
append_in(cons(X, XS), YS, cons(X, ZS)) → U1(X, XS, YS, ZS, append_in(XS, YS, ZS))
append_in(nil, XS, XS) → append_out(nil, XS, XS)
U1(X, XS, YS, ZS, append_out(XS, YS, ZS)) → append_out(cons(X, XS), YS, cons(X, ZS))
U3(X, XS, YS, append_out(ZS, cons(X, nil), YS)) → reverse_out(cons(X, XS), YS)
U4(X, XS, YS, reverse_out(XS, ZS)) → U5(X, XS, YS, shuffle_in(ZS, YS))
shuffle_in(nil, nil) → shuffle_out(nil, nil)
U5(X, XS, YS, shuffle_out(ZS, YS)) → shuffle_out(cons(X, XS), cons(X, YS))
U6(XS, shuffle_out(cons(X, XS), YS)) → query_out(XS)

The argument filtering Pi contains the following mapping:
query_in(x1)  =  query_in(x1)
U6(x1, x2)  =  U6(x2)
shuffle_in(x1, x2)  =  shuffle_in(x1)
cons(x1, x2)  =  cons(x2)
U4(x1, x2, x3, x4)  =  U4(x4)
reverse_in(x1, x2)  =  reverse_in(x1)
U2(x1, x2, x3, x4)  =  U2(x4)
nil  =  nil
reverse_out(x1, x2)  =  reverse_out(x2)
U3(x1, x2, x3, x4)  =  U3(x4)
append_in(x1, x2, x3)  =  append_in(x1, x2)
U1(x1, x2, x3, x4, x5)  =  U1(x5)
append_out(x1, x2, x3)  =  append_out(x3)
U5(x1, x2, x3, x4)  =  U5(x4)
shuffle_out(x1, x2)  =  shuffle_out(x2)
query_out(x1)  =  query_out
APPEND_IN(x1, x2, x3)  =  APPEND_IN(x1, x2)

We have to consider all (P,R,Pi)-chains
For (infinitary) constructor rewriting [30] we can delete all non-usable rules from R.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
                ↳ UsableRulesProof
PiDP
                    ↳ PiDPToQDPProof
              ↳ PiDP
              ↳ PiDP

Pi DP problem:
The TRS P consists of the following rules:

APPEND_IN(cons(X, XS), YS, cons(X, ZS)) → APPEND_IN(XS, YS, ZS)

R is empty.
The argument filtering Pi contains the following mapping:
cons(x1, x2)  =  cons(x2)
APPEND_IN(x1, x2, x3)  =  APPEND_IN(x1, x2)

We have to consider all (P,R,Pi)-chains
Transforming (infinitary) constructor rewriting Pi-DP problem [30] into ordinary QDP problem [15] by application of Pi.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
                ↳ UsableRulesProof
                  ↳ PiDP
                    ↳ PiDPToQDPProof
QDP
                        ↳ QDPSizeChangeProof
              ↳ PiDP
              ↳ PiDP

Q DP problem:
The TRS P consists of the following rules:

APPEND_IN(cons(XS), YS) → APPEND_IN(XS, YS)

R is empty.
Q is empty.
We have to consider all (P,Q,R)-chains.
By using the subterm criterion [20] together with the size-change analysis [32] we have proven that there are no infinite chains for this DP problem.

From the DPs we obtained the following set of size-change graphs:



↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
PiDP
                ↳ UsableRulesProof
              ↳ PiDP

Pi DP problem:
The TRS P consists of the following rules:

REVERSE_IN(cons(X, XS), YS) → REVERSE_IN(XS, ZS)

The TRS R consists of the following rules:

query_in(XS) → U6(XS, shuffle_in(cons(X, XS), YS))
shuffle_in(cons(X, XS), cons(X, YS)) → U4(X, XS, YS, reverse_in(XS, ZS))
reverse_in(cons(X, XS), YS) → U2(X, XS, YS, reverse_in(XS, ZS))
reverse_in(cons(X, nil), cons(X, nil)) → reverse_out(cons(X, nil), cons(X, nil))
reverse_in(nil, nil) → reverse_out(nil, nil)
U2(X, XS, YS, reverse_out(XS, ZS)) → U3(X, XS, YS, append_in(ZS, cons(X, nil), YS))
append_in(cons(X, XS), YS, cons(X, ZS)) → U1(X, XS, YS, ZS, append_in(XS, YS, ZS))
append_in(nil, XS, XS) → append_out(nil, XS, XS)
U1(X, XS, YS, ZS, append_out(XS, YS, ZS)) → append_out(cons(X, XS), YS, cons(X, ZS))
U3(X, XS, YS, append_out(ZS, cons(X, nil), YS)) → reverse_out(cons(X, XS), YS)
U4(X, XS, YS, reverse_out(XS, ZS)) → U5(X, XS, YS, shuffle_in(ZS, YS))
shuffle_in(nil, nil) → shuffle_out(nil, nil)
U5(X, XS, YS, shuffle_out(ZS, YS)) → shuffle_out(cons(X, XS), cons(X, YS))
U6(XS, shuffle_out(cons(X, XS), YS)) → query_out(XS)

The argument filtering Pi contains the following mapping:
query_in(x1)  =  query_in(x1)
U6(x1, x2)  =  U6(x2)
shuffle_in(x1, x2)  =  shuffle_in(x1)
cons(x1, x2)  =  cons(x2)
U4(x1, x2, x3, x4)  =  U4(x4)
reverse_in(x1, x2)  =  reverse_in(x1)
U2(x1, x2, x3, x4)  =  U2(x4)
nil  =  nil
reverse_out(x1, x2)  =  reverse_out(x2)
U3(x1, x2, x3, x4)  =  U3(x4)
append_in(x1, x2, x3)  =  append_in(x1, x2)
U1(x1, x2, x3, x4, x5)  =  U1(x5)
append_out(x1, x2, x3)  =  append_out(x3)
U5(x1, x2, x3, x4)  =  U5(x4)
shuffle_out(x1, x2)  =  shuffle_out(x2)
query_out(x1)  =  query_out
REVERSE_IN(x1, x2)  =  REVERSE_IN(x1)

We have to consider all (P,R,Pi)-chains
For (infinitary) constructor rewriting [30] we can delete all non-usable rules from R.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
              ↳ PiDP
                ↳ UsableRulesProof
PiDP
                    ↳ PiDPToQDPProof
              ↳ PiDP

Pi DP problem:
The TRS P consists of the following rules:

REVERSE_IN(cons(X, XS), YS) → REVERSE_IN(XS, ZS)

R is empty.
The argument filtering Pi contains the following mapping:
cons(x1, x2)  =  cons(x2)
REVERSE_IN(x1, x2)  =  REVERSE_IN(x1)

We have to consider all (P,R,Pi)-chains
Transforming (infinitary) constructor rewriting Pi-DP problem [30] into ordinary QDP problem [15] by application of Pi.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
              ↳ PiDP
                ↳ UsableRulesProof
                  ↳ PiDP
                    ↳ PiDPToQDPProof
QDP
                        ↳ QDPSizeChangeProof
              ↳ PiDP

Q DP problem:
The TRS P consists of the following rules:

REVERSE_IN(cons(XS)) → REVERSE_IN(XS)

R is empty.
Q is empty.
We have to consider all (P,Q,R)-chains.
By using the subterm criterion [20] together with the size-change analysis [32] we have proven that there are no infinite chains for this DP problem.

From the DPs we obtained the following set of size-change graphs:



↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
              ↳ PiDP
PiDP
                ↳ UsableRulesProof

Pi DP problem:
The TRS P consists of the following rules:

SHUFFLE_IN(cons(X, XS), cons(X, YS)) → U41(X, XS, YS, reverse_in(XS, ZS))
U41(X, XS, YS, reverse_out(XS, ZS)) → SHUFFLE_IN(ZS, YS)

The TRS R consists of the following rules:

query_in(XS) → U6(XS, shuffle_in(cons(X, XS), YS))
shuffle_in(cons(X, XS), cons(X, YS)) → U4(X, XS, YS, reverse_in(XS, ZS))
reverse_in(cons(X, XS), YS) → U2(X, XS, YS, reverse_in(XS, ZS))
reverse_in(cons(X, nil), cons(X, nil)) → reverse_out(cons(X, nil), cons(X, nil))
reverse_in(nil, nil) → reverse_out(nil, nil)
U2(X, XS, YS, reverse_out(XS, ZS)) → U3(X, XS, YS, append_in(ZS, cons(X, nil), YS))
append_in(cons(X, XS), YS, cons(X, ZS)) → U1(X, XS, YS, ZS, append_in(XS, YS, ZS))
append_in(nil, XS, XS) → append_out(nil, XS, XS)
U1(X, XS, YS, ZS, append_out(XS, YS, ZS)) → append_out(cons(X, XS), YS, cons(X, ZS))
U3(X, XS, YS, append_out(ZS, cons(X, nil), YS)) → reverse_out(cons(X, XS), YS)
U4(X, XS, YS, reverse_out(XS, ZS)) → U5(X, XS, YS, shuffle_in(ZS, YS))
shuffle_in(nil, nil) → shuffle_out(nil, nil)
U5(X, XS, YS, shuffle_out(ZS, YS)) → shuffle_out(cons(X, XS), cons(X, YS))
U6(XS, shuffle_out(cons(X, XS), YS)) → query_out(XS)

The argument filtering Pi contains the following mapping:
query_in(x1)  =  query_in(x1)
U6(x1, x2)  =  U6(x2)
shuffle_in(x1, x2)  =  shuffle_in(x1)
cons(x1, x2)  =  cons(x2)
U4(x1, x2, x3, x4)  =  U4(x4)
reverse_in(x1, x2)  =  reverse_in(x1)
U2(x1, x2, x3, x4)  =  U2(x4)
nil  =  nil
reverse_out(x1, x2)  =  reverse_out(x2)
U3(x1, x2, x3, x4)  =  U3(x4)
append_in(x1, x2, x3)  =  append_in(x1, x2)
U1(x1, x2, x3, x4, x5)  =  U1(x5)
append_out(x1, x2, x3)  =  append_out(x3)
U5(x1, x2, x3, x4)  =  U5(x4)
shuffle_out(x1, x2)  =  shuffle_out(x2)
query_out(x1)  =  query_out
SHUFFLE_IN(x1, x2)  =  SHUFFLE_IN(x1)
U41(x1, x2, x3, x4)  =  U41(x4)

We have to consider all (P,R,Pi)-chains
For (infinitary) constructor rewriting [30] we can delete all non-usable rules from R.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
              ↳ PiDP
              ↳ PiDP
                ↳ UsableRulesProof
PiDP
                    ↳ PiDPToQDPProof

Pi DP problem:
The TRS P consists of the following rules:

SHUFFLE_IN(cons(X, XS), cons(X, YS)) → U41(X, XS, YS, reverse_in(XS, ZS))
U41(X, XS, YS, reverse_out(XS, ZS)) → SHUFFLE_IN(ZS, YS)

The TRS R consists of the following rules:

reverse_in(cons(X, XS), YS) → U2(X, XS, YS, reverse_in(XS, ZS))
reverse_in(cons(X, nil), cons(X, nil)) → reverse_out(cons(X, nil), cons(X, nil))
reverse_in(nil, nil) → reverse_out(nil, nil)
U2(X, XS, YS, reverse_out(XS, ZS)) → U3(X, XS, YS, append_in(ZS, cons(X, nil), YS))
U3(X, XS, YS, append_out(ZS, cons(X, nil), YS)) → reverse_out(cons(X, XS), YS)
append_in(cons(X, XS), YS, cons(X, ZS)) → U1(X, XS, YS, ZS, append_in(XS, YS, ZS))
append_in(nil, XS, XS) → append_out(nil, XS, XS)
U1(X, XS, YS, ZS, append_out(XS, YS, ZS)) → append_out(cons(X, XS), YS, cons(X, ZS))

The argument filtering Pi contains the following mapping:
cons(x1, x2)  =  cons(x2)
reverse_in(x1, x2)  =  reverse_in(x1)
U2(x1, x2, x3, x4)  =  U2(x4)
nil  =  nil
reverse_out(x1, x2)  =  reverse_out(x2)
U3(x1, x2, x3, x4)  =  U3(x4)
append_in(x1, x2, x3)  =  append_in(x1, x2)
U1(x1, x2, x3, x4, x5)  =  U1(x5)
append_out(x1, x2, x3)  =  append_out(x3)
SHUFFLE_IN(x1, x2)  =  SHUFFLE_IN(x1)
U41(x1, x2, x3, x4)  =  U41(x4)

We have to consider all (P,R,Pi)-chains
Transforming (infinitary) constructor rewriting Pi-DP problem [30] into ordinary QDP problem [15] by application of Pi.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
              ↳ PiDP
              ↳ PiDP
                ↳ UsableRulesProof
                  ↳ PiDP
                    ↳ PiDPToQDPProof
QDP
                        ↳ RuleRemovalProof

Q DP problem:
The TRS P consists of the following rules:

SHUFFLE_IN(cons(XS)) → U41(reverse_in(XS))
U41(reverse_out(ZS)) → SHUFFLE_IN(ZS)

The TRS R consists of the following rules:

reverse_in(cons(XS)) → U2(reverse_in(XS))
reverse_in(cons(nil)) → reverse_out(cons(nil))
reverse_in(nil) → reverse_out(nil)
U2(reverse_out(ZS)) → U3(append_in(ZS, cons(nil)))
U3(append_out(YS)) → reverse_out(YS)
append_in(cons(XS), YS) → U1(append_in(XS, YS))
append_in(nil, XS) → append_out(XS)
U1(append_out(ZS)) → append_out(cons(ZS))

The set Q consists of the following terms:

reverse_in(x0)
U2(x0)
U3(x0)
append_in(x0, x1)
U1(x0)

We have to consider all (P,Q,R)-chains.
By using the rule removal processor [15] with the following polynomial ordering [25], at least one Dependency Pair or term rewrite system rule of this QDP problem can be strictly oriented.
Strictly oriented dependency pairs:

SHUFFLE_IN(cons(XS)) → U41(reverse_in(XS))
U41(reverse_out(ZS)) → SHUFFLE_IN(ZS)


Used ordering: POLO with Polynomial interpretation [25]:

POL(SHUFFLE_IN(x1)) = 2·x1   
POL(U1(x1)) = 1 + x1   
POL(U2(x1)) = 2 + x1   
POL(U3(x1)) = 2·x1   
POL(U41(x1)) = 1 + x1   
POL(append_in(x1, x2)) = x1 + x2   
POL(append_out(x1)) = x1   
POL(cons(x1)) = 1 + x1   
POL(nil) = 0   
POL(reverse_in(x1)) = 2·x1   
POL(reverse_out(x1)) = 2·x1   



↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ AND
              ↳ PiDP
              ↳ PiDP
              ↳ PiDP
                ↳ UsableRulesProof
                  ↳ PiDP
                    ↳ PiDPToQDPProof
                      ↳ QDP
                        ↳ RuleRemovalProof
QDP
                            ↳ PisEmptyProof

Q DP problem:
P is empty.
The TRS R consists of the following rules:

reverse_in(cons(XS)) → U2(reverse_in(XS))
reverse_in(cons(nil)) → reverse_out(cons(nil))
reverse_in(nil) → reverse_out(nil)
U2(reverse_out(ZS)) → U3(append_in(ZS, cons(nil)))
U3(append_out(YS)) → reverse_out(YS)
append_in(cons(XS), YS) → U1(append_in(XS, YS))
append_in(nil, XS) → append_out(XS)
U1(append_out(ZS)) → append_out(cons(ZS))

The set Q consists of the following terms:

reverse_in(x0)
U2(x0)
U3(x0)
append_in(x0, x1)
U1(x0)

We have to consider all (P,Q,R)-chains.
The TRS P is empty. Hence, there is no (P,Q,R) chain.